#include <cstdio>
#include <ctime>

#define DBG_LEVEL 0
#define INF_LEVEL 1
#define ERR_LEVEL 2
#define DEFAULT_LEVEL DBG_LEVEL
#define LOG(level_str, level, format, ...)                                                                  \
    {                                                                                                       \
        if (level >= DEFAULT_LEVEL)                                                                         \
        {                                                                                                   \
            time_t t = time(NULL);                                                                          \
            struct tm *ptm = localtime(&t);                                                                 \
            char time_str[32];                                                                              \
            strftime(time_str, 31, "%H:%M:%S", ptm);                                                        \
            printf("[%s][%s][%s:%d] " format "\n", level_str, time_str, __FILE__, __LINE__, ##__VA_ARGS__); \
        }                                                                                                   \
    }

#define DLOG(format, ...) LOG("DBG", DBG_LEVEL, format, ##__VA_ARGS__)
#define ILOG(format, ...) LOG("INF", INF_LEVEL, format, ##__VA_ARGS__)
#define ELOG(format, ...) LOG("ERR", ERR_LEVEL, format, ##__VA_ARGS__)

int main()
{
    // 日志 [12:02:21][log.cc][8] 打印日志信息
    DLOG("%d-DBG", 1);
    ILOG("%d-INF", 2);
    ELOG("%d-ERR", 3);
    return 0;
}